using Behaving;
using Behaving.Actions;
using Behaving.Decorators;
using FluentAssertions;
using NUnit.Framework;

namespace Behaving.Tests.DecoratorTests
{
    [TestFixture]
    public class WaitCounterTests
    {
        [Test]
        public void Counter_works()
        {
            ExecutionCounter executionCounter;
            BehaviourTree behaviourTree = new BehaviourTree(new WaitCounter(executionCounter = new ExecutionCounter(RunningState.Running), 3));
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasNotCalled(executionCounter); 
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasNotCalled(executionCounter); 
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasNotCalled(executionCounter); 
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasStartedAndExecuted(executionCounter); 

            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasStopped(executionCounter); 
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasNotCalled(executionCounter); 
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasNotCalled(executionCounter);
            behaviourTree.Tick().Should().Be(RunningState.Running);
            Assertions.AssertWasStartedAndExecuted(executionCounter); 
        }
    }
}